<template>
	<m-page :pageData="pageData">
		<view slot="content">
			<m-income :pageData="pages" @goPage="goPage" @clickDetail="clickDetail" :list="list"></m-income>
		</view>
	</m-page>
</template>

<script>
	export default {
		data() {
			return {
				pageData:{
					showBrand:false,
					showTips:true,
					title:'消息通知',
					diy:true,
					m:true,
				},
				pages:{
					"page": 1,
					"page_size": 10,
					total:0,
					msg:true,
				},
				list:[]
			}
		},
		onShow() {
			this.getPageList()
		},
		methods: {
			clickDetail(item){
				// uni.setStorageSync('msgContent',item.content)
				// this.utils.goPath('/pages/message/detail/detail',{id:item.Id})
				
			},
			msgUpdateStatus(){
				let par = {
					id:this.list.map(item => {return item.Id})
				}
				this.$api.msgUpdateStatus(par).then(res => {
					if(res.code == 200){
					}
				})
			},
			goPage(val){
				this.pages.page = val
				this.getPageList()
			},
			getPageList(){
				let par = {
					"page": this.pages.page,
				    "page_size": this.pages.page_size,
					user_id:this.loginInfo.user_id
				}
				this.$api.msgList(par).then(res => {
					if(res.code == 200){
						res.data.list && res.data.list.map((d,index) => {
							// "【"+(d.msg_type == 1?'所有团队':d.msg_type == 2?'团队':'个人')+"】" +
							d.msg = true;
							d.title =  d.content
							d.index = index
						})
						this.list = res.data.list || [];
						this.pages.total = res.data.count
						this.msgUpdateStatus()
					}
				})
			},
		}
	}
</script>

<style>

</style>
